<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>全部商品目录</title>
	<link href="${pageContext.request.contextPath }/client/css/main.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css">
</head>
<body>
	<%@include file="./include/head.jsp" %>
	<%@include file="./include/menu_search.jsp" %>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

	<div class="container product_list-wrap">
		<c:if test="${products.size() == 0}">
			<div class="alert alert-danger" role="alert">很抱歉，查询不到相关的图书！</div>
		</c:if>
	
		<div class="row">
			<c:forEach items="${products}" var="p">
				<div class="col-md-3">
					<div class="thumbnail">
						<img src="<c:out value="${p.imgurl}"/>" alt="<c:out value="${p.name}"/>" style="width: 100%; height: 250px;">
						<div class="caption">
							<form action="${pageContext.request.contextPath}/AddShoppingCartServlet" method="post">
								<input type="hidden" name="id" value="<c:out value="${p.id}" />">
								<input type="hidden" name=imgurl value="<c:out value="${p.imgurl}" />">
								<div class="form-group">
									<label for="exampleInputEmail1">书名</label>
									<c:out value="${p.name}"/>
	    							<input type="hidden" name="PName" class="form-control" value="<c:out value="${p.name}"/>">
								</div>
								<div class="form-group">
									<label for="exampleInputEmail1">售价</label>
									<c:out value="${p.price}"/>
	    							<input type="hidden" name="Price" class="form-control" value="<c:out value="${p.price}"/>">
								</div>
								<div class="form-group">
									<label for="exampleInputEmail1">库存</label>
									<c:out value="${p.pnum}"/>
	    							<input type="hidden" name="PNum" class="form-control" value="<c:out value="${p.pnum}"/>">
								</div>
								<div class="clearfix">
									<a class="btn btn-primary pull-right" href="${pageContext.request.contextPath }/ProductDetailServlet?id=${p.id}">商品详情</a>
									<button type="submit" class="btn btn-default pull-right" style="margin-right: 10px;">加入购物车</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</c:forEach>
		</div>
		<nav>
		  <ul class="pager">
		  	<c:if test="${hasPrev}">
		  		<li class="previous"><a href="${pageContext.request.contextPath}/AllProductServlet?page=${_page - 1}"><span aria-hidden="true">&larr;</span>上一页</a></li>
		  	</c:if>
		  	<c:if test="${hasNext}">
		    	<li class="next"><a href="${pageContext.request.contextPath}/AllProductServlet?page=${_page + 1}">下一页 <span aria-hidden="true">&rarr;</span></a></li>
		  	</c:if>
		  </ul>
		</nav>
	</div>
	
	<%@include file="./include/foot.jsp" %>
</body>
</html>